//服务器：初始化和启动服务器的文件
#include "log.hpp"
#include "TcpServer.hpp"
#include "Protocol.hpp"
#include "servercalc.hpp"
#include "log.hpp"

#include <iostream>
#include <memory>

void Usage(const std::string& proc)
{
    std::cout << "\n\rUsage: " << proc << "port[1024+]\n" << std::endl;
}

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(1);
    }
    uint16_t serverport = std::stoi(argv[1]);

    ServerCalc cal;
    TcpServer *tsvr = new TcpServer(serverport, std::bind(&ServerCalc::Calculator, &cal, std::placeholders::_1));
    LOG(Info, "server init...");
    tsvr->InitServer();
    LOG(Info, "server init success");
    LOG(Info, "server start..");
    tsvr->StartServer();
    return 0;
}